<template>
	<view style="margin-top: 100px;">
		<text style="font-size: 25px;margin-left: 50px;margin-top: 50px;">登录注册\n\n</text>
		<text style="font-size: 25px;margin-left: 50px;">体验更好的交流方式</text>
		<text>\n\n\n\n</text>
		 <view style="margin-left: 100px;margin-bottom: 50px;">
			 <view>用户名:<input class="input_class" v-model="username" /></view>
			 <view>密码:<input class="input_class" v-model="password"  /></view>
		 </view>
		 <view style="margin-top: 10px;margin-left: 100px;">
		 			 <button @click="login()" style="float: left;width: 100px;height: 50px;">登录</button>
		 			 <button @click="gotoRegist()" style="float: left;width: 100px;height: 50px;">注册</button>
		 </view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				username:"",
				password:""
			}
		},
		methods: {
			gotoRegist(){
				uni.navigateTo({url:'../regist/regist'});
			},
			login(){
				var username=this.username;
				var password=this.password;
				uni.request({
					url:this.requestUrl+"/ForeUserController/findByUsernameAndPassword?username="+username+"&password="+password,
					method:"GET",
					success:response =>{
						if(response.data!=null&&response.data!=undefined&&response.data!=""){
							uni.setStorageSync("user",response.data);
							uni.switchTab({url:'../school/school'});
						}else{
							uni.showToast({title: '账号或密码错误'});
						}
					}
				})
				
			}
			
		}
	}
</script>

<style>
.input_class{
	background: #F1F1F1;
	width: 375rpx;
}
</style>
